package cn.iocoder.yudao.module.wms.dal.mysql.rdrecord08;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.wms.controller.admin.rdrecord08.vo.Rdrecord08PageReqVO;
import cn.iocoder.yudao.module.wms.dal.dataobject.rdrecord08.Rdrecord08DO;
import org.apache.ibatis.annotations.Mapper;

import java.util.Collection;

/**
 * 其他入库主 Mapper
 *
 * @author 曾劲松
 */
@Mapper
public interface Rdrecord08Mapper extends BaseMapperX<Rdrecord08DO> {

    default PageResult<Rdrecord08DO> selectPage(Rdrecord08PageReqVO reqVO, Collection<String> personIds,
                                                Collection<String> deptIds, Collection<String> warehouseIds,
                                                Collection<String> creator, Collection<String> auditor) {
        return selectPage(reqVO, new LambdaQueryWrapperX<Rdrecord08DO>()
                .likeIfPresent(Rdrecord08DO::getSerialNumber, reqVO.getSerialNumber())
                .inIfPresent(Rdrecord08DO::getPersonId, personIds)
                .inIfPresent(Rdrecord08DO::getDeptId, deptIds)
                .inIfPresent(Rdrecord08DO::getWarehouseId, warehouseIds)
                .betweenIfPresent(Rdrecord08DO::getOrderDate, reqVO.getOrderDate())
                .likeIfPresent(Rdrecord08DO::getRemark, reqVO.getRemark())
                .inIfPresent(Rdrecord08DO::getCreator, creator)
                .betweenIfPresent(Rdrecord08DO::getCreateTime, reqVO.getCreateTime())
                .inIfPresent(Rdrecord08DO::getAuditor, auditor)
                .betweenIfPresent(Rdrecord08DO::getAuditTime, reqVO.getAuditTime())
                .eqIfPresent(Rdrecord08DO::getStatus, reqVO.getStatus())
                .orderByDesc(Rdrecord08DO::getId));
    }

    default Rdrecord08DO selectBySerialNumber(String serialNumber) {
        return selectOne(Rdrecord08DO::getSerialNumber, serialNumber);
    }

    default Rdrecord08DO selectByProcessInstanceId(String processInstanceId) {
        return selectOne(Rdrecord08DO::getProcessInstanceId, processInstanceId);
    }

}